<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title>邮件信息列表</title>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/meta.jsp"%>
</head>
<body>
<div class="x-panel-header">内部邮件</div>
<div class="x-toolbar" style="height: 25px;  padding:3px 5px;">
   <form action="index.do" method="post">
  <table width="99%">
    <tr>
      <td>
	  <span>
	    <s:if test="#attr.mailIndexType == 'send'">
	      <img src="${ctx}/images/icons/folder_go.gif">
		  &nbsp;<font color="#909090"><b>已发邮件</b></font>
		  
	    </s:if>
	    <s:elseif test="#attr.mailIndexType == 'receive'">
	      <img src="${ctx}/images/icons/folder-in.gif">
	      &nbsp;<font color="green"><b>已收邮件</b></font>
	      <input type="hidden" name="mailIndexType" value="receive">
	    </s:elseif>
	  </span>
	 
		主题：<s:textfield name="model.subject" size="20"/>
		&nbsp;&nbsp;
		从：<input type="text" name="startDate" readonly="readonly" style="width: 100px" value='<s:date name="startDate" format="yyyy-MM-dd"/>' onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>&nbsp;
		至：<input type="text" name="endDate" readonly="readonly" style="width: 100px" value='<s:date name="endDate" format="yyyy-MM-dd"/>' onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="查询" class="button">
	
      </td>
      <td align="right">
	  	<a href="newMail.do">
	  	  <img src="${ctx}/images/icons/mail.gif">&nbsp;写邮件
	  	</a>
	  	<a href="#" onclick="remove()">
	  	  <img src="${ctx}/images/icons/delete.gif">&nbsp;删除
	  	</a>
      </td>
    </tr>
  </table>
  </form>
</div>
<ec:table items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
	action="index.do" 
	useAjax="false"
	doPreload="false" 
	pageSizeList="10,20,50" 
	editable="false"
	sortable="false" 
	rowsDisplayed="10" 
	generateScript="true"
	resizeColWidth="true" 
	classic="false" 
	width="100%" 
	height="320px"
	minHeight="320"
	showHeader="true"
	toolbarContent="navigation|pagejump|pagesize|refresh|extend|status">
	<ec:row>
		<ec:column width="45" property="_select" title="选择" style="text-align:center;">
		  <input type="checkbox" name="selectedItems" value="${item.id}" style="border:0px;"/>
		</ec:column>
		<s:if test="#attr.mailIndexType == 'send'">
		  <ec:column width="200" property="_receive_send" title="接收人" ellipsis="true" >
			<div title="${item.mail.recipientNames}">${item.mail.recipientNames}</div>
		  </ec:column>
		  <ec:column width="200" property="_receive_send" title="抄送人" ellipsis="true" >
			<div title="${item.mail.copyToNames}">${item.mail.copyToNames}</div>
		  </ec:column>
		</s:if>
		<s:elseif test="#attr.mailIndexType == 'receive'">
		  <ec:column width="200" property="_receive_send" title="发送人" ellipsis="true">
			<div title="${item.mail.senderName}">
			  <s:if test="#attr.item.isRead == 0"><img src="${ctx}/images/icons/mail_2.gif"></s:if>
			  <s:else>&nbsp;&nbsp;</s:else>
			  ${item.mail.senderName}
			</div>
		  </ec:column>
		</s:elseif>
		<ec:column width="350" property="_mail.subject" title="主题" ellipsis="true" style="border-left:0px; border-right:0px;">
		  <div title="${item.mail.subject}">
		    <a href="#" onclick="view('${item.id}')">
		      <s:if test="#attr.item.isRead == 0">
				<b>${item.mail.subject}</b>
			  </s:if>
			  <s:else>
				${item.mail.subject}
			  </s:else>
		    </a>
		  </div>
		</ec:column>
		<ec:column width="40" property="_attch" title="附件" style="border-left:0px; text-align:center;">
		  <s:if test="#attr.item.mail.fileIds != null">
		    <img src="${ctx}/images/icons/attachment.gif" title="有附件信息">	
		  </s:if>
		</ec:column>
		<ec:column width="130" property="sendTime" title="发送时间" cell="date" format="yyyy-MM-dd HH:mm" style="border-left:0px;text-align:center;"/>
	</ec:row>
</ec:table>
<script type="text/javascript">

 
function remove(){
	 var sels = document.getElementsByName("selectedItems");
	    var checked = false;;
	    for(i = 0; i < sels.length; i++) {
	        if(sels[i].checked) {
	           checked = true;
	           break;
	        }
	    } 
	    if(!checked) {
	    	alert("请选择要删除的邮件!");
	    	return;
	    }
	    if (confirm("确定要删除所选择的邮件吗？删除后不能恢复!")){
	        	var from = document.getElementById("ec");
	    		from.action="removeMailBox.do";
	    		from.submit();
	    }
}

function view(id){
	window.location.href="view.do?mailId=" + id;
}

</script>
</body>
</html>